import { createRouter, createWebHistory } from "vue-router";
import Layout from "layouts/index.vue";

export const routes = [
  {
    path: "/",
    component: Layout,
    meta: { title: "项目实战", icon: "el-icon-s-tools" },
    children: [
      {
        path: "/jsx",
        component: () => import("views/jsx.vue"),
        meta: { title: "JSX Demo", icon: "el-icon-s-release" },
      },
      {
        path: "/store",
        component: () => import("views/store.vue"),
        meta: { title: "Store Demo", icon: "el-icon-s-goods" },
      },
      {
        path: "/element3",
        component: () => import("views/element3.vue"),
        meta: { title: "Element3 Demo", icon: "el-icon-platform-eleme" },
      },
      {
        path: "/mock",
        component: () => import("views/mock.vue"),
        meta: { title: "Mock Demo", icon: "el-icon-s-help" },
      },
    ],
  },
  {
    path: "/users",
    name: "users",
    component: Layout,
    meta: {
      title: "用户管理",
      icon: "el-icon-user-solid",
    },
    redirect: "/users/list",
    children: [
      {
        path: "list",
        name: "userList",
        component: () => import("views/users/list.vue"),
        meta: {
          title: "用户列表",
          icon: "el-icon-document",
        },
      },
      {
        path: "create",
        name: "userCreate",
        component: () => import("views/users/create.vue"),
        hidden: true,
        meta: {
          title: "创建新用户",
          activeMenu: "/users/list",
        },
      },
      {
        path: "edit/:id(\\d+)",
        name: "userEdit",
        component: () => import("views/users/edit.vue"),
        hidden: true,
        meta: {
          title: "编辑用户信息",
          activeMenu: "/users/list",
        },
      },
    ],
  },
];

const router = createRouter({
  history: createWebHistory("/vvd"),
  routes,
});

export default router;
